import javax.microedition.lcdui.Graphics;

public class ba {

	public static boolean G = false;
	public ba H;
	public o I;
	public Object J;
	public bk K;
	public int L;
	public short M;
	public short N;
	public short O;

	private ba() {
		K = new bk();
		L = 18;
	}

	public ba(o o1) {
		K = new bk();
		L = 18;
		I = o1;
	}

	public ba(o o1, int i1, int j1) {
		K = new bk();
		L = 18;
		I = o1;
		N = (short) i1;
		O = (short) j1;
	}

	public final aj q() {
		ba ba1 = this;
		while (ba1 != null) {
			if (ba1 instanceof aj)
				return (aj) ba1;
			else
				ba1 = ba1.H;
		}
		return null;
	}

	public ah b() {
		ba ba1 = this;
		while (ba1 != null) {
			if (ba1 instanceof ah)
				return (ah) ba1;
			else
				ba1 = ba1.H;
		}
		return null;
	}

	public boolean a(int ai[]) {
		return false;
	}

	public int e() {
		return 0;
	}

	public int f() {
		return 0;
	}

	public int g_() {
		return 0;
	}

	public ba a(int i1) {
		return null;
	}

	public void a(int i1, ba ba1) {
	}

	public final ba b(Object obj) {
		int i1 = g_();
		for (int j1 = 0; j1 < i1; j1++) {
			ba ba1 = a(j1);
			if (ba1.J == obj)
				return ba1;
		}

		for (int k1 = 0; k1 < i1; k1++) {
			ba ba2 = a(k1).b(obj);
			if (ba2 != null)
				return ba2;
		}

		return null;
	}

	public final ba r() {
		return a(0);
	}

	public final ba s() {
		return a(g_() - 1);
	}

	public final int d(ba ba1) {
		if (ba1 != null) {
			int i1 = 0;
			for (int j1 = g_(); i1 < j1; i1++)
				if (a(i1) == ba1)
					return i1;

		}
		return -1;
	}

	public final ba e(ba ba1) {
		int i1 = 0;
		for (int j1 = g_(); i1 < j1; i1++)
			if (a(i1) == ba1)
				if (i1 + 1 < j1)
					return a(i1 + 1);
				else
					return null;

		return null;
	}

	public final ba f(ba ba1) {
		int i1 = 0;
		for (int j1 = g_(); i1 < j1; i1++)
			if (a(i1) == ba1)
				if (i1 > 0)
					return a(i1 - 1);
				else
					return null;

		return null;
	}

	public final ba i(int i1) {
		M = (short) i1;
		return this;
	}

	public final g t() {
		return I.b();
	}

	public int g() {
		return 0;
	}

	public int g(int i1) {
		return 0;
	}

	public int u() {
		int i1 = N;
		if (i1 == 0)
			i1 = I.c;
		if (i1 == 0) {
			i1 = g();
			if (i1 > 0) {
				i1 += I.g();
			}
		}
		return i1;
	}

	public final boolean v() {
		return N != 0 || I.c != 0;
	}

	public final boolean w() {
		return O != 0 || I.d != 0;
	}

	public final int j(int i1) {
		int j1 = O;
		if (j1 == 0)
			j1 = I.d;
		if (j1 == 0) {
			j1 = g(i1 - I.g());
			if (j1 >= 0) {
				j1 += I.h();
			}
		}
		return j1;
	}

	public final ba k(int i1) {
		N = (short) i1;
		return this;
	}

	public final ba l(int i1) {
		O = (short) i1;
		return this;
	}

	public final ba d(int i1, int j1) {
		N = (short) i1;
		O = (short) j1;
		return this;
	}

	public final int x() {
		return K.f;
	}

	public final int y() {
		return K.g;
	}

	public final void z()
    {
        ba ba1 = H;
        if(ba1 == null)
            ba1 = this;
        else {
        	do {
        		ba1 = ba1.H;
        	} while (ba1 instanceof ap);
        }
        if(ba1 != null)
            bh.b().c(ba1);
    }

	public final void a(ba ba1, ba ba2) {
		aj aj1 = q();
		if (aj1 != null && aj1.b == ba1) {
			if (ba2 == null) {
				ba ba3 = aj.a(true, ba1);
				if (ba3 == null) {
					ba3 = aj.a(false, ba1);
					aj1.a(ba3, 6);
				} else {
					aj1.a(ba3, 1);
				}
			} else {
				aj1.a(ba2, 1);
			}
		}
		ba1.H = null;
		return;
	}

	public int a(int i1, int j1, int k1, int l1) {
		if (l1 == 0)
			return g(k1);
		else
			return l1;
	}

	public void b(int i1, int j1, int k1, int l1) {
		K.b(i1, j1, k1, l1);
		o o1 = I;
		int i2;
		if ((i2 = l1) > 0)
			i2 -= o1.h();
		i2 = a(i1 + o1.c(), j1 + o1.e(), k1 - o1.g(), i2);
		if (l1 == 0)
			K.g = (short) (i2 + o1.h());
	}

	public void a(Graphics g1, bh bh1, o o1, int i1, int j1) {
	}

	public void a(Graphics g1, bh bh1) {
		o o1 = I;
		if (H != null)
			o1 = o1.a(G());
		int i1 = x();
		int j1 = y();
		o1.a(this, g1, i1, j1, true);
		i1 -= o1.g();
		j1 -= o1.h();
		if (G) {
			g1.setColor(0xff0000);
			g1.setStrokeStyle(0);
			g1.drawRect(0, 0, i1 - 1, j1 - 1);
			a(g1, bh1, o1, i1, j1);
			g1.setStrokeStyle(0);
			return;
		} else {
			a(g1, bh1, o1, i1, j1);
			return;
		}
	}

	public final void A() {
		if ((L & 0x200) == 0)
			bh.b().d(this);
		else
			bh.b().d(H);
	}

	public final void B() {
		bh bh1;
		(bh1 = bh.b()).d(this);
		bh1.n();
	}

	public final boolean C() {
		return (L & 2) != 0;
	}

	public final boolean D() {
		return (L & 8) != 0;
	}

	public final boolean E() {
		return (L & 0x10) != 0;
	}

	public final boolean F() {
		return (L & 3) == 3;
	}

	public final boolean G() {
		aj aj1 = q();
		if (aj1 != null)
			return aj1.c(this);
		else
			return false;
	}

	public boolean a(int i1, int j1) {
		if (i1 != 2 && M != 0 && (j1 == -5 || j1 == 10)) {
			bh.b().a(this, M);
			return true;
		} else {
			return false;
		}
	}

	public boolean a(int i1, int j1, int k1) {
		int l1 = g_();
		for (int i2 = 0; i2 < l1; i2++) {
			ba ba1 = a(i2);
			if (ba1.K.a(j1, k1) && ba1.a(i1, j1, k1))
				return true;
		}

		aj aj1 = q();
		if (aj1 != null && F() && i1 == 1) {
			if (aj1.b == this)
				a(1, -5);
			else
				aj1.a(this, 6);
			return true;
		} else {
			return false;
		}
	}

	public final void m(int i1) {
		short word0 = H.K.f;
		short word1 = H.K.d;
		if (i1 != 0) {
			word0 -= i1 - word1;
			if ((H.I.e & 1) != 0)
				word0 -= i1 - word1;
			word1 = (short) i1;
		}
		if (K.d >= word1)
			K.d = (short) ((word1 + word0) - ((K.d - word1) + K.f));
		a();
	}

	public void a() {
	}

}